import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import APlayer from "./js/aplayer";

Vue.prototype.$APlayer = APlayer

Vue.prototype.$audio = []

Vue.use(ElementUI)

Vue.use(VueAxios, axios)

Vue.config.productionTip = false

//请求拦截器
axios.interceptors.request.use((config) => {
  config.headers.Authorization = 'Bearer ' + window.localStorage.getItem('token');
  return config;
});

//响应拦截器
axios.interceptors.response.use((res) => {
  if (res.data.code == 401) {
    
    // alert('请先登录');
    // this.$message({
    //   message: '请先登录',
    //   type: 'warning'
    // });
    // this.$router.push('/');
    // $router.push('/')
    // console.log("11",this.$router);
  }
  return res;
}, err => {
  return Promise.reject(err);
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
